<template>
  <gui-page>
    <template v-slot:gBody>
      <view style="padding: 0 25rpx">
        <view
          v-for="(item, index) in receiveList"
          @tap="goNoticeDetail(item)"
          class="gui-margin-top gui-bg-white gui-border-radius-large gui-border-box"
          style="padding: 20rpx 30rpx 5rpx"
        >
          <view
            class="xhs-font32 xhs-letter-spacing1"
            style="height: 30rpx; line-height: 30rpx"
            >{{ item.noticeTitle }}</view
          >
          <view
            class="xhs-margin-top-15 xhs-font24 xhs-gray-color1"
            style="height: 20rpx"
            >{{ formatDate(item.createTime) }}</view
          >
          <view
            class="gui-margin-top xhs-font28 gui-border-b xhs-letter-spacing1 xhs-gray-color1"
            style="padding-bottom: 30rpx"
          >
            {{ item.noticeContent }}
          </view>
          <view
            class="xhs-margin-top-15 xhs-font28 gui-flex gui-space-between gui-align-items-center"
          >
            <view>查看详情</view>
            <view>
              <text
                class="gui-form-icon gui-icons gui-text-center gui-color-gray"
                >&#xe601;
              </text>
            </view>
          </view>
        </view>

        <gui-loadmore
          v-show="receiveList.length > 0"
          :loadMoreText="[
            '上划加载更多',
            '更多数据加载中',
            '已加载全部数据',
            '暂无数据',
          ]"
          ref="loadmorecom1"
          :status="1"
        ></gui-loadmore>

        <!--					为空展示-->
        <gui-empty v-show="receiveList.length == 0" style="height: 800rpx">
          <template v-slot:img>
            <view class="gui-flex gui-rows gui-justify-content-center">
              <text
                class="gui-icons gui-empty-icon gui-color-gray"
                style="font-size: 80rpx"
                >&#xe6b8;
              </text>
            </view>
          </template>
          <template v-slot:text>
            <text
              class="gui-block gui-text-center xhs-margin-top-30 gui-color-gray"
              >暂时没有通知信息~</text
            >
          </template>
        </gui-empty>
      </view>
    </template>
  </gui-page>
</template>
<script>
import commonMixin from "@/mixin/commonMinxin";

export default {
  mixins: [commonMixin],
  data() {
    return {
      items: [],
      page: 1,
      receiveList: [],
    };
  },
  onLoad: function () {
    this.getReceivePage();
    uni.app.post("/auth/readAuthorReceive", "", "", "", (res) => {});
  },
  onReachBottom: function () {
    console.log("到底了");
    var status = this.$refs["loadmorecom1"].loadMoreStatus;
    if (status == 2) return;
    this.getReceivePage();
  },
  onPullDownRefresh: function () {
    console.log("下拉刷新了");
    this.page = 1;
    this.getReceivePage(1);
  },
  methods: {
    goNoticeDetail(e) {
      uni.app.navigate("/pages/webView/webView?redirectUrl=" + e.redirectUrl);
    },
    //格式化时间
    formatDate(date) {
      return uni.app.formatDate(date);
    },
    getReceivePage(isReload) {
      uni.app.get(
        "/auth/getReceivePage",
        { limit: 10, page: this.page },
        "",
        (res) => {
          if (this.page <= res.data.pages) {
            if (this.page == 1) {
              this.receiveList = res.data.records;
            } else {
              this.receiveList = [...this.receiveList, ...res.data.records];
            }
            if (this.page == res.data.pages) {
              //停止加载更多
              this.$refs.loadmorecom1.nomore();
            } else {
              this.page++;
              this.$refs.loadmorecom1.stoploadmore();
            }
          } else if (res.data.pages == 0) {
            this.$refs.loadmorecom1.nomore();
          }
        },
      );

      if (isReload) {
        uni.stopPullDownRefresh();
      }
    },
  },
};
</script>
<style scoped></style>
